package com.safeneeds.linguimana.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.safeneeds.linguimana.entity.PortNewsCate;
import com.safeneeds.linguimana.ser.IBgNewsCateService;
import com.safeneeds.util.base.BaseAction;
import com.safeneeds.util.base.IUserInfo;
import com.safeneeds.util.base.RetType;

/**
 * 门户后台新闻管理
 * @author gaof
 * @date 2017年2月7日
 */
@Controller
@RequestMapping("bgPort")
public class BgNewsCateAction extends BaseAction{

	@Resource(name="bgNewsCateService")
	private IBgNewsCateService bgNewsCateService;
	
	/**
	 * 获取新闻类分类列表登录
	 * @return
	 */
	@RequestMapping("listNewsCateLogin.do")
	public String listNewsCateLogin(){
		return getViewsModelPathSys("portmana/bg/newsCate/newsCateList");
	}
	
	/**
	 * 获取新闻类分类列表
	 * @return
	 */
	@ResponseBody
	@RequestMapping("listNewsCate.ido")
	public RetType depaList(){
		RetType reType = bgNewsCateService.listNewsCate();
		
		return reType;
	}
	
	/**
	 * 添加/编辑新闻分类
	 * @return
	 */
	@ResponseBody
	@RequestMapping("addNewsCate.ido")
	public RetType addDepa(HttpServletRequest request, PortNewsCate cate){
		
		IUserInfo userInfo = getUserInfo(request);
		RetType reType = bgNewsCateService.addNewsCate(cate, userInfo);
		
		return reType;
	}
	
	/**
	 * 删除新闻分类
	 * @return
	 */
	@ResponseBody
	@RequestMapping("delNewsCate.ido")
	public RetType delNewsCate(String id){
		
		RetType reType = bgNewsCateService.delNewsCate(id);
		
		return reType;
	}
	
}
